Skip to content

Conversation

@Anipaleja
Copy link

Summary

Improves error handling for SCollection.unionAll when called with empty collections by providing a clear, actionable error message that guides users to the appropriate API.

Problem

The SCollection.unionAll method throws an unclear exception when called with an empty collection, leaving users confused about the correct approach. Meanwhile, ScioContext.unionAll properly handles empty collections but users weren't aware of this alternative.

Solution

  • Enhanced error message: SCollection.unionAll now throws an IllegalArgumentException with a clear message pointing users to ScioContext.unionAll for empty-safe operations
  • Improved API consistency: Both methods now have well-defined, documented behavior
  • Better user experience: Users get immediate guidance on the correct API to use

Changes

  • Updated SCollection.unionAll to provide descriptive error message for empty input
  • Added comprehensive test coverage for both SCollection.unionAll and ScioContext.unionAll
  • Tests verify error message content and proper handling of single/multiple collections

Testing

  • Added unit tests for empty collection error case
  • Added tests for single and multiple collection scenarios
  • Verified ScioContext.unionAll continues to handle empty collections correctly
  • All existing tests pass

Backwards Compatibility

This change is backwards compatible - it only improves the error message for a previously failing case. No existing working code is affected.

Related Issues

Fixes #1092

Anipaleja added 3 commits July 1, 2025 15:37
- Add descriptive error message for SCollection.unionAll with empty input
- Point users to ScioContext.unionAll for empty-safe operations
- Add comprehensive test coverage for both companion object and context methods
- Ensure consistent behavior and clear API guidance

Fixes spotify#1092
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SCollection#unionAll throws an exception on empty list

1 participant